<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1" import="com.DAO.*,java.util.*,com.beans.*"%>
    <%!int i=0;String str=null; %>
  <%@taglib prefix="getData" uri="/WEB-INF/CustomTagDescriptor.tld" %>  
   <%@taglib prefix="html" uri="/tags/struts-html" %> 
   
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<link rel = "stylesheet" href = "style/Global.css" />
<script language="javaScript" type="text/javascript" src="scripts/calendar.js"></script>
<script language="javaScript" type="text/javascript" src="scripts/Global.js"></script>
   <link href="style/calendar.css" rel="stylesheet" type="text/css">
</head>
<%
 String op=request.getParameter("op");
if(op!=null)
{
    
    if(op.equals("next")){
    	   
    	   String counter=request.getParameter("counter");
    	   if(counter==null){
    		   i=0;    		   
    	   }
    	   else{
    		   
    		    i=Integer.parseInt(counter)+1;
    	   }
       }   
    } 
    else
    {
    	String counter=request.getParameter("counter");
    	if(counter==null){
 		   i=0;    		   
 	   }
 	   else if(Integer.parseInt(counter)>0){
 		     i=Integer.parseInt(counter)-1;
 	   }
    	
    }

%>



<body onload = "loadDefaultExpiryDate()">
	<fieldset id = "postform">
		<legend>
			Notice
		</legend>
		<form method="post" action="NoticeForm.do">
			
				<table>
				<html:errors/>
				
				<tr>
					<td>
						<div class = "titletext">Category</div>
					</td>
					<td>
						<select class = "inputelement" name="categoryName">
							<%!					
								CategoryDAO categorydao = new CategoryDAO();
							    ArrayList<CategoryForm> cl=null;
							%>
							<%					
							String user=(String)session.getAttribute("user_type");
							try {
							
								
								cl = categorydao.get();
								for(int i = 0; i < cl.size(); i++){
									            
												if(!cl.get(i).getName().equals("Announcements") 
														&& !cl.get(i).getName().equals("Birthday")
														&& !cl.get(i).getName().equals("Client Appreciation")) {
													%><option><%=cl.get(i).getName() %></option><%
												} else if(user.equals("admin")) {
													%><option><%=cl.get(i).getName() %></option><%
												}								
									}
								} catch(Exception e) {
									
								}
								%>
						</select>						
					</td>
					<td>
						<div class = "titletext">Expiry Date</div>
					</td>
					<td>
							<input id = datum" class = "inputelement" type = "text" name = "expirationDate">
							<a href="#" onClick="setYears(2012, 2020);showCalender(this, 'expirationDate');">
						    <img src="image/calender.png"></a>
									
									 <!-- Calender Script  --> 
						
						    <table id="calenderTable">
						        <tbody id="calenderTableHead">
						          <tr>
						            <td colspan="4" align="center">
							          <select onChange="showCalenderBody(createCalender(document.getElementById('selectYear').value,
							           this.selectedIndex, false));" id="selectMonth">
							              <option value="0">Jan</option>
							              <option value="1">Feb</option>
							              <option value="2">Mar</option>
							              <option value="3">Apr</option>
							              <option value="4">May</option>
							              <option value="5">Jun</option>
							              <option value="6">Jul</option>
							              <option value="7">Aug</option>
							              <option value="8">Sep</option>
							              <option value="9">Oct</option>
							              <option value="10">Nov</option>
							              <option value="11">Dec</option>
							          </select>
						            </td>
						            <td colspan="2" align="center">
									    <select onChange="showCalenderBody(createCalender(this.value, 
										document.getElementById('selectMonth').selectedIndex, false));" id="selectYear">
										</select>
									</td>
						            <td align="center">
									    <a href="#" onClick="closeCalender();"><font color="#003333" size="+1">X</font></a>
									</td>
								  </tr>
						       </tbody>
						       <tbody id="calenderTableDays">
						         <tr style="">
						           <td>Sun</td><td>Mon</td><td>Tue</td><td>Wed</td><td>Thu</td><td>Fri</td><td>Sat</td>
						         </tr>
						       </tbody>
						       <tbody id="calender"></tbody>
						    </table>
						
						<!-- End Calender Script  --> 
					</td>
				</tr>
				<tr>
					<td>
						<div class = "titletext">Title</div>
					</td>
					<td colspan = "3">
						<input class = "inputelementlarge" type = "text" onkeypress="return imposeMaxLength(this, 100);" name="title">
						<html:errors property="title"/>
					</td>
				</tr>				
				<tr>
					<td>
						<div class = "titletext">Discription</div>
					</td>
					<td colspan = "3">
						<textarea class = "inputelementlarge" rows="3" onkeypress="return imposeMaxLength(this, 500);" name="description"></textarea>
						<html:errors property="description"/>
					</td>
				</tr>
				<tr>
					<td colspan = "4">
						<input  id = "btnsubmit" type = "submit" name = "submit" value = "Post">
					</td>
				</tr>
				</table>
		</form>
	</fieldset>
	<%str=i+""; %>
	
	<getData:notice1 cursor="<%=str%>" category="0"/>
	
	<div id = "pager">	 
	<a id = "btnprev" href="noticeform-1.jsp?counter=<%=str%>&op=pre"> &lt;&lt;</a>
	<a id = "btnnext" href="noticeform-1.jsp?counter=<%=str%>&op=next">&gt;&gt; </a>	 
	</div>
	
</body>


</html>